﻿$.MGJ.SMSApi = [];

(function () {
    var _this = $.MGJ.SMSApi;

    $.extend($.MGJ.SMSApi, {
        Dialog_PhoneVerifyObj: null,
        Dialog_PhoneVerify: function (obj) {
            var id = $(obj).attr("ID");
            this.Dialog_PhoneVerifyObj = $.L.dialog({
                url: ACTION_URL("PhoneVerify", "ConfigManager")  ,
                title: "验证接口",
                width:600,
                height: 'auto',
                buttons: {
                    "btnVerify": {
                        type: 'primary',
                        text: '验证',
                        click: function () {
                            VerifySms();
                        }
                    }
                },
            });
        }
    });

})(jQuery);
(function () {
    var _this = $.MGJ.SMSApi;

    $.extend($.MGJ.SMSApi, {
        //验证
    

        //添加
        Ajax_Save: function () {
     
            // _this.Dialog_PhoneVerify();

            $.L.ajaxHandle({
                type: "POST",
                url: ACTION_URL("SMSApiSave", "ConfigManager"),
                data: $("#SMSApiInfo").serialize(),
                success: function (res) {
                    if (res=="True") {
                        $.L.msgSuccess("操作成功！");
                        $("#SMSApiInfo input").attr("readonly", "readonly");
                        _this.Dialog_PhoneVerifyObj.close();
                        _this.Ajax_BindLoad();
                      
                    }
                    else
                        $.L.msgError("操作失败！");
                }
            });
        },
        //默认加载  如果有数据 就改为编辑状态
        Ajax_BindLoad: function () {
            
            $.L.ajaxHandle({
                url: ACTION_URL("SMSApiModel", "ConfigManager"),
                success: function (response) {
                    if (response)
                    {
                        $("#ID").val(response.ID);
                        $("#Name").val(response.Name);
                        $("#Appkey").val(response.Appkey);
                        $("#ModelCode").val(response.ModelCode);
                    }
                    if (response.state || 0 == 1) {
                        $("#Appkey,#ModelCode").attr("readonly", "readonly");
                        $("#smsEditBtn").show();
                        $("#smsSaveBtn").hide();
                        $("#checkoutImg").attr("src", "/Content/webImgs/Config/ok.svg");
                    }
                    else {
                        $("#Appkey,#ModelCode").removeAttr("readonly");
                        $("#checkoutImg").attr("src", "/Content/webImgs/Config/no.svg");
                        $("#smsSaveBtn").show();
                        $("#smsEditBtn").hide();
                    }
                    $("#checkoutImg").show();
                },
                error: function (r) {
                

                }
            });
        }
    });
})(jQuery);